const { exec, escape } = require('../db/mysql')
const { genPassword } = require('../utils/cryp')

const login = async (username, password) => {
    // username = escape(username)

    // 生成加密密码
    // password = genPassword(password)
    // password = escape(password)
    const sql = `
    SELECT uid,uname,uhead,ustatement,upoint,URegDate FROM bbsuser WHERE uname='${username}' AND upassword='${password}' `
    // console.log('sql is', sql)

    const rows = await exec(sql)
    
    return rows[0] || {}
}

module.exports = {
    login
}